* Replication file

* Citation:
* John Gerring, Carl Henrik Knutsen, Matthew Maguire, Svend-Erik Skaaning, Jan Teorell, and Michael Coppedge. 2021. “Democracy and Human Development: Issues of Conceptualization and Measurement.” Democratization 28(2): 308-332.

* Set directory
cd "~/Dropbox/Replication/2021_Democratization"

****************************************************************
****************************************************************
**************** Main Tables and Figures ***********************
****************************************************************
****************************************************************

* Table 1: Democracy indices
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 Level */ preserve
qui rename e_polity2_pos democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_1_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var' democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_1_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}
/* 2 Stock (10%) */ preserve
qui rename e_polity2_pos_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_1_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var'_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_1_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}
/* 3 Stock (10%), Lagged DV */ preserve
qui rename e_polity2_pos_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo imr_gapminder_ipo_ln i.year, fe vce(cluster country_id)
outreg2 using Table_1_3.xls, label se dec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var'_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo imr_gapminder_ipo_ln i.year, fe vce(cluster country_id)
outreg2 using Table_1_3.xls, label se dec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}
/* 4 Stock (1%) */ preserve
qui rename e_polity2_pos_stock_1 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_1_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var'_stock_1 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_1_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}

* Figure 1: Horse-race tests
* See 2021_Democratization_replication_Figure_1.R
* Full results in Table D6

* Table 2: MPI and mortality
* Uses measurement model posteriors. Each model run from a separate .do file.
* See Table C12 for results without measurement error

* Figure 2: Varying aggregation rules
* See 2021_Democratization_replication_Figure_2.R
* Full results in Table D7

****************************************************************
****************************************************************
* Appendix B: Variable Descriptions and Descriptive Statistics *
****************************************************************
****************************************************************

* Table B2: Descriptive statistics
use "2021_Democratization_replication_data_10yr.dta", clear
order imr_gapminder_ipo_ln wdi_mort_ln cme_gapminder_ipo_ln le_gapminder_ipo_85mln edi_mult edi_mult_stock_1 edi_mult_stock_10 v2xel_frefair v2x_elecoff v2x_frassoc_thick v2x_freexp_thick v2x_suffr e_migdppcln_ipo e_miurbani  e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 e_polity2_pos e_polity2_pos_stock_1 e_polity2_pos_stock_10 e_uds_mean_pos e_uds_mean_pos_stock_1 e_uds_mean_pos_stock_10 contdim contdim_stock_1 contdim_stock_10 partdim partdim_stock_1 partdim_stock_10 miller_mult miller_mult_stock_1 miller_mult_stock_10 v2x_partip v2x_partip_stock_1 v2x_partip_stock_10 v2xdl_delib v2xdl_delib_stock_1 v2xdl_delib_stock_10 v2x_gender v2x_gender_stock_1 v2x_gender_stock_10 v2x_cspart v2x_cspart_stock_1 v2x_cspart_stock_10 v2xcl_rol v2xcl_rol_stock_1 v2xcl_rol_stock_10 e_boix_regime e_boix_regime_stock_1 e_boix_regime_stock_10 e_bnr_dem e_bnr_dem_stock_1 e_bnr_dem_stock_10 globalEDmt_minus regionEDmt_minus inreversewave
keep(imr_gapminder_ipo_ln wdi_mort_ln cme_gapminder_ipo_ln le_gapminder_ipo_85mln edi_mult edi_mult_stock_1 edi_mult_stock_10 v2xel_frefair v2x_elecoff v2x_frassoc_thick v2x_freexp_thick v2x_suffr e_migdppcln_ipo e_miurbani  e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 e_polity2_pos e_polity2_pos_stock_1 e_polity2_pos_stock_10 e_uds_mean_pos e_uds_mean_pos_stock_1 e_uds_mean_pos_stock_10 contdim contdim_stock_1 contdim_stock_10 partdim partdim_stock_1 partdim_stock_10 miller_mult miller_mult_stock_1 miller_mult_stock_10 v2x_partip v2x_partip_stock_1 v2x_partip_stock_10 v2xdl_delib v2xdl_delib_stock_1 v2xdl_delib_stock_10 v2x_gender v2x_gender_stock_1 v2x_gender_stock_10 v2x_cspart v2x_cspart_stock_1 v2x_cspart_stock_10 v2xcl_rol v2xcl_rol_stock_1 v2xcl_rol_stock_10 e_boix_regime e_boix_regime_stock_1 e_boix_regime_stock_10 e_bnr_dem e_bnr_dem_stock_1 e_bnr_dem_stock_10 globalEDmt_minus regionEDmt_minus inreversewave)
quietly outreg2 using Table_B2.doc, bdec(3) replace sum(log)

****************************************************************
****************************************************************
**************** Appendix C: Robustness ************************
****************************************************************
****************************************************************

* Table C1: MPI and mortality
* Same as Table 2

* Table C2: Restricted sample tests
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=1, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=1 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=2, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=2 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=3, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=3 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=4, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=4 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 9. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=5, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 10. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=5 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=6, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 12. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=6 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 13. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=7, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 14. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=7 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 15. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=8, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 16. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=8 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 17. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=10, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 18. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if ht_regioncf !=10 & year > 1939, fe vce(cluster country_id)
qui outreg2 using Table_C2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C3: Tests of functional form
use "2021_Democratization_replication_data_10yr.dta", clear
gen imr_gapminder_ipo_ln_sqrt = sqrt(imr_gapminder_ipo_ln)
xtset country_id trend
/* 1. */ qui xtreg F.imr_gapminder_ipo_ln_sqrt edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. */ qui xtreg F.d.imr_gapminder_ipo_ln_sqrt d.edi_mult_stock_10 d.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_C3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. */ preserve
qui tobit F.imr_gapminder_ipo edi_mult_stock_10 e_migdppcln_ipo i.year, ll(.4) vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
qui outreg2 using Table_C3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", `years', "Countries", e(N_clust), "Observations", e(N), "R-squared", e(r2_p)) eqkeep(imr_gapminder_ipo) excel append
restore
/* 4. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year if edi_mult_stock_10 > 0, fe vce(cluster country_id)
qui outreg2 using Table_C3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C4: Possible non-linearities in MPI stock
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ qui xtreg F.imr_gapminder_ipo_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. */ qui xtreg F.imr_gapminder_ipo_ln c.edi_mult_stock_10##c.edi_mult_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. */ qui gen edi_mult_stock_10sq = edi_mult_stock_10*edi_mult_stock_10
qui xtreg F.D.imr_gapminder_ipo_ln D.edi_mult_stock_10 D.edi_mult_stock_10sq D.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 4. */ qui xtreg F.imr_gapminder_ipo_ln c.edi_mult_stock_10##c.edi_mult_stock_10 i.year , fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5. */ qui xtreg F.imr_gapminder_ipo_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6. */ preserve
use "2021_Democratization_replication_data_10yr_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppc infmor_gapminder edi_mult_stock_10 infmor_clio)
qui mi stset, clear
qui mi xtset country_id trend
qui gen e_migdppc_ln = ln(e_migdppc)
qui gen infmor_gapminder_ln = ln(infmor_gapminder)
qui mibeta F.infmor_gapminder_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppc_ln i.year i.country_id, vce(cluster country_id)
qui local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.infmor_gapminder_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppc_ln i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 7. */ qui xtreg F.imr_gapminder_ipo_ln c.L2.edi_mult_stock_10##c.L2.edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8. */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppcln_ipo year, gmm(edi_mult_stock_10, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 9. */ qui xtreg F.wdi_mort_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 10. */ qui xtreg F.cme_gapminder_ipo_ln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11. */ qui xtreg F.le_gapminder_ipo_85mln c.edi_mult_stock_10##c.edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C5: Instrumental variable tests
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo i.year (edi_mult_stock_10  = inreversewave), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Kleibergen-Paap F", e(widstat)) excel replace 
/* 2. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo i.year (edi_mult_stock_10  = regionEDmt_minus), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Kleibergen-Paap F", e(widstat)) excel append 
/* 3. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo i.year (edi_mult_stock_10 = inreversewave regionEDmt_minus), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Hansen J-test p-value", e(jp), "Kleibergen-Paap F", e(widstat)) excel append
/* 4. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo regionimr_minus globalimr_minus i.year (edi_mult_stock_10  = inreversewave regionEDmt_minus globalEDmt_minus), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Hansen J-test p-value", e(jp), "Kleibergen-Paap F", e(widstat)) excel append 
/* 5. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo i.year (edi_mult_stock_10  = inreversewave regionEDmt_minus globalEDmt_minus), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Hansen J-test p-value", e(jp), "Kleibergen-Paap F", e(widstat)) excel append 
/* 6. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo regionimr_minus globalimr_minus i.year (edi_mult  = inreversewave regionEDmt_minusl globalEDmt_minusl), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Hansen J-test p-value", e(jp), "Kleibergen-Paap F", e(widstat)) excel append 
/* 7. */ qui xi: xtivreg2 F.imr_gapminder_ipo_ln e_migdppcln_ipo i.year (edi_mult  = inreversewave regionEDmt_minusl globalEDmt_minusl), fe first cluster(country_id) partial(i.year)
qui outreg2 using Table_C5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "Hansen J-test p-value", e(jp), "Kleibergen-Paap F", e(widstat)) excel append

* Table C6: Possible non-linearities in GDP
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 c.e_migdppcln_ipo##c.e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 c.e_migdppcln_ipo##c.e_migdppcln_ipo c.e_migdppcln_ipo#c.e_migdppcln_ipo#c.e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C7: Additional tests of MPI level
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.D.imr_gapminder_ipo_ln D.edi_mult D.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult i.year , fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ preserve
use "2021_Democratization_replication_data_10yr_MI_level.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppc infmor_gapminder edi_mult infmor_clio)
qui mi stset, clear
qui mi xtset country_id trend
qui gen e_migdppc_ln = ln(e_migdppc)
qui gen infmor_gapminder_ln = ln(infmor_gapminder)
qui mibeta F.infmor_gapminder_ln edi_mult e_migdppc_ln i.year i.country_id, vce(cluster country_id)
qui local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.infmor_gapminder_ln edi_mult e_migdppc_ln i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 7 */ qui xtreg F.imr_gapminder_ipo_ln L2.edi_mult e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo year, gmm(edi_mult, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 9. */ qui xtreg F.wdi_mort_ln edi_mult e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 10. */ qui xtreg F.cme_gapminder_ipo_ln edi_mult e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11. */ qui xtreg F.le_gapminder_ipo_85mln edi_mult e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C8: Tests of MPI using Driscoll-Kraay standard errors
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
qui tabulate year, generate(yr)
qui gen f_imr_gapminder_ipo_ln = F.imr_gapminder_ipo_ln
qui gen f_wdi_mort_ln = F.wdi_mort_ln
qui gen f_cme_gapminder_ipo_ln = F.cme_gapminder_ipo_ln
qui gen f_le_gapminder_ipo_85mln = F.le_gapminder_ipo_85mln
qui gen l2_edi_mult_stock_10 = L2.edi_mult_stock_10
qui gen f_d_imr_gapminder_ipo_ln = F.D.imr_gapminder_ipo_ln
qui gen d_edi_mult_stock_10 = D.edi_mult_stock_10
qui gen d_e_migdppcln_ipo = D.e_migdppcln_ipo
/* 1 */ qui xtscc f_imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel replace
drop sample
/* 2 */ qui xtscc f_imr_gapminder_ipo_ln edi_mult_stock_1 e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 3 */ qui xtscc f_imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 4 */ qui xtscc f_imr_gapminder_ipo_ln edi_mult_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 5 */ qui xtscc f_d_imr_gapminder_ipo_ln d_edi_mult_stock_10 d_e_migdppcln_ipo yr*, pooled
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2)) excel append
drop sample
/* 6 */ qui xtscc f_imr_gapminder_ipo_ln edi_mult_stock_10 yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 7 */ qui xtscc f_imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 8 */ qui xtreg f_imr_gapminder_ipo_ln l2_edi_mult_stock_10 e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 9. */ qui xtscc f_wdi_mort_ln edi_mult_stock_10 e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append
drop sample
/* 10. */ qui xtscc f_le_gapminder_ipo_85mln edi_mult_stock_10 e_migdppcln_ipo yr*, fe
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using Table_C8.xls, label se bdec(3) noni noobs nor nocon nonot drop(yr*) ctitle(" ") addstat("Countries", `countries', "Years", `years',"Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C9: Tests of MPI and GDPpc (ln) stock (10%)
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_1 e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.D.imr_gapminder_ipo_ln D.edi_mult_stock_10 D.e_migdppcln_ipo_10 i.year, re vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 6 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo_10 e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.imr_gapminder_ipo_ln L2.edi_mult_stock_10 e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo_10 year, gmm(edi_mult_stock_10, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 9. */ qui xtreg F.wdi_mort_ln edi_mult_stock_10 e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 10. */ qui xtreg F.cme_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11. */ qui xtreg F.le_gapminder_ipo_85mln edi_mult_stock_10 e_migdppcln_ipo_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C10: Tests of MPI using annual data
* Uses posteriors from measurement model. Each model run from a separate .do file.

* Table C11: Tests of MPI and political durability
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 durable i.year, fe vce(cluster country_id)
qui outreg2 using Table_C11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_1 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 durable i.year, fe vce(cluster country_id)
qui outreg2 using Table_C11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 durable i.year, fe vce(cluster country_id)
qui outreg2 using Table_C11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo_10 e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 durable i.year, fe vce(cluster country_id)
qui outreg2 using Table_C11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_1 e_migdppcln_ipo_10 e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 durable i.year, fe vce(cluster country_id)
qui outreg2 using Table_C11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo_10 e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 durable i.year, fe vce(cluster country_id)
qui outreg2 using Table_C11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C12: Tests of MPI not including measurement error
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ gen trend2 = trend^2
gen trend3 = trend^3
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo trend trend2 trend3, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 imr_gapminder_ipo_ln l.imr_gapminder_ipo_ln l2.imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.D.imr_gapminder_ipo_ln edi_mult_stock_10 D.edi_mult_stock_10 D.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 7 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 i.year , fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 9 */ 
preserve
use "2021_Democratization_replication_data_10yr_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppc infmor_gapminder edi_mult_stock_10 infmor_clio)
qui mi stset, clear
qui mi xtset country_id trend
qui gen e_migdppc_ln = ln(e_migdppc)
qui gen infmor_gapminder_ln = ln(infmor_gapminder)
qui mibeta F.infmor_gapminder_ln edi_mult_stock_10 e_migdppc_ln i.year i.country_id, vce(cluster country_id)
qui local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.infmor_gapminder_ln edi_mult_stock_10 e_migdppc_ln i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xtreg F.imr_gapminder_ipo_ln L2.edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11 */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo year, gmm(edi_mult_stock_10, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 12 */ qui xtreg F.wdi_mort_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 13 */ qui xtreg F.cme_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 14 */ qui xtreg F.le_gapminder_ipo_85mln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C13: Democracy indices using data from 1960-present
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
drop if year < 1960
/* 1 Level */ preserve
qui rename e_polity2_pos democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_C13_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var' democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_C13_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}
/* 2 Stock (10%) */ preserve
qui rename e_polity2_pos_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_C13_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var'_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_C13_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}
/* 3 Stock (10%), Lagged DV */ preserve
qui rename e_polity2_pos_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo imr_gapminder_ipo_ln i.year, fe vce(cluster country_id)
outreg2 using Table_C13_3.xls, label se dec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var'_stock_10 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo imr_gapminder_ipo_ln i.year, fe vce(cluster country_id)
outreg2 using Table_C13_3.xls, label se dec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}
/* 4 Stock (1%) */ preserve
qui rename e_polity2_pos_stock_1 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_C13_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
foreach var of varlist e_uds_mean_pos contdim partdim v2x_partip v2xdl_delib v2x_gender v2x_cspart v2xcl_rol e_boix_regime e_bnr_dem miller_mult edi_mult {
preserve
qui rename `var'_stock_1 democ
qui xtreg F.imr_gapminder_ipo_ln democ e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_C13_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("`var'") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
}

* Table C14: Additional tests of BMR
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln e_boix_regime_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln e_boix_regime e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ gen trend2 = trend^2
gen trend3 = trend^3
qui xtreg F.imr_gapminder_ipo_ln e_boix_regime_stock_10 e_migdppcln_ipo trend trend2 trend3, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln e_boix_regime_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.D.imr_gapminder_ipo_ln D.e_boix_regime_stock_10 D.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 6 */ qui xtreg F.imr_gapminder_ipo_ln e_boix_regime_stock_10 i.year , fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.imr_gapminder_ipo_ln e_boix_regime_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ qui xtreg F.imr_gapminder_ipo_ln L2.e_boix_regime_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 9 */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln e_boix_regime_stock_10 e_migdppcln_ipo year, gmm(e_boix_regime_stock_10, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 10. */ qui xtreg F.wdi_mort_ln e_boix_regime_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11. */ qui xtreg F.cme_gapminder_ipo_ln e_boix_regime_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 12. */ qui xtreg F.le_gapminder_ipo_85mln e_boix_regime_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table C15: Additional tests of BNR
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln e_bnr_dem_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln e_bnr_dem e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ gen trend2 = trend^2
gen trend3 = trend^3
qui xtreg F.imr_gapminder_ipo_ln e_bnr_dem_stock_10 e_migdppcln_ipo trend trend2 trend3, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln e_bnr_dem_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.D.imr_gapminder_ipo_ln D.e_bnr_dem_stock_10 D.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 6 */ qui xtreg F.imr_gapminder_ipo_ln e_bnr_dem_stock_10 i.year , fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.imr_gapminder_ipo_ln e_bnr_dem_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ qui xtreg F.imr_gapminder_ipo_ln L2.e_bnr_dem_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 9 */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln e_bnr_dem_stock_10 e_migdppcln_ipo year, gmm(e_bnr_dem_stock_10, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 10. */ qui xtreg F.wdi_mort_ln e_bnr_dem_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 11. */ qui xtreg F.cme_gapminder_ipo_ln e_bnr_dem_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 12. */ qui xtreg F.le_gapminder_ipo_85mln e_bnr_dem_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_C15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

****************************************************************
****************************************************************
***** Appendix D: The Multiplicative Polyarchy Index (MPI) *****
****************************************************************
****************************************************************

* Table D1: MPI level by country in 2000
use "2021_Democratization_replication_data_10yr.dta", clear
keep if year == 2000
keep country_name edi_mult
gsort -edi_mult country_name
replace edi_mult = round(edi_mult, 0.001)
export excel using "Table_D1", replace

* Table D2: Correlation matrix of MPI components
use "2021_Democratization_replication_data_10yr.dta", clear
corr v2xel_frefair v2x_elecoff v2x_frassoc_thick v2x_freexp_thick v2x_suffr
sum v2xel_frefair v2x_elecoff v2x_frassoc_thick v2x_freexp_thick v2x_suffr if v2xel_frefair != . & v2x_elecoff != . & v2x_frassoc_thick != . & v2x_freexp_thick != . & v2x_suffr != .
mkcorr v2xel_frefair v2x_elecoff v2x_frassoc_thick v2x_freexp_thick v2x_suffr, casewise log(Table_D2) cdec(3) mdec(3) replace

* Table D3: Excluding components of MPI
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. MPI, benchmark */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
gen sample = e(sample)
qui outreg2 using Table_D3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. MPI, excluding clean elections */ qui xtreg F.imr_gapminder_ipo_ln mpi_frefair_stock_10 e_migdppcln_ipo i.year if sample == 1, fe vce(cluster country_id)
qui outreg2 using Table_D3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. MPI, excluding elected executive */ qui xtreg F.imr_gapminder_ipo_ln mpi_elecoff_stock_10  e_migdppcln_ipo i.year if sample == 1, fe vce(cluster country_id)
qui outreg2 using Table_D3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4. MPI, excluding suffrage */ qui xtreg F.imr_gapminder_ipo_ln mpi_suffr_stock_10 e_migdppcln_ipo i.year if sample == 1, fe vce(cluster country_id)
qui outreg2 using Table_D3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5. MPI, excluding free association */ qui xtreg F.imr_gapminder_ipo_ln mpi_frassoc_stock_10 e_migdppcln_ipo i.year if sample == 1, fe vce(cluster country_id)
qui outreg2 using Table_D3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6. MPI, excluding free expression */ qui xtreg F.imr_gapminder_ipo_ln mpi_freexp_stock_10 e_migdppcln_ipo i.year if sample == 1, fe vce(cluster country_id)
qui outreg2 using Table_D3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table D4: Disaggregating MPI
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. clean elections */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. elected executive */ qui xtreg F.imr_gapminder_ipo_ln v2x_elecoff_stock_10  e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. suffrage */ qui xtreg F.imr_gapminder_ipo_ln v2x_suffr_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4. free association */ qui xtreg F.imr_gapminder_ipo_ln v2x_frassoc_thick_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5. free expression */ qui xtreg F.imr_gapminder_ipo_ln v2x_freexp_thick_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table D5: Additional tests of clean elections
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1 */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2 */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair_stock_1 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair_stock_10 imr_gapminder_ipo_ln e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.D.imr_gapminder_ipo_ln D.v2xel_frefair_stock_10 D.e_migdppcln_ipo i.year, re vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_o)) excel append
/* 6 */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair_stock_10 i.year , fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.imr_gapminder_ipo_ln v2xel_frefair_stock_10 e_migdppcln_ipo e_miurbani e_miferrat_ln e_migdpgro e_miinterc e_miinteco v2x_corr_stock_10 i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 9 */ qui xtreg F.imr_gapminder_ipo_ln L2.v2xel_frefair_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 10 */ qui xi: xtabond2 f.imr_gapminder_ipo_ln imr_gapminder_ipo_ln L.imr_gapminder_ipo_ln v2xel_frefair_stock_10 e_migdppcln_ipo year, gmm(v2xel_frefair_stock_10, lag (3 5)) iv(year) robust artests(3)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
/* 11. */ qui xtreg F.wdi_mort_ln v2xel_frefair_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 12. */ qui xtreg F.cme_gapminder_ipo_ln v2xel_frefair_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 13. */ qui xtreg F.le_gapminder_ipo_85mln v2xel_frefair_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Figure D1: Histograms of MPI stock (10%) and MPI level in 2000
use "2021_Democratization_replication_data_annual.dta", clear
label variable edi_mult_stock_10 "MPI stock (10%)"
label variable edi_mult "MPI level"
qui hist edi_mult_stock_10 if year == 2000, graphregion(color(white)) color(gs14) lcolor(gs7) saving(stock, replace)
qui hist edi_mult if year == 2000, graphregion(color(white)) color(gs14) lcolor(gs7) saving(level, replace)
qui gr combine stock.gph level.gph, graphregion(color(white)) col(1)
graph export "Figure_D1.pdf", replace

* Figure D2: MPI level and Polity2 in 1900
use "2021_Democratization_replication_data_annual.dta", clear
label variable edi_mult "MPI, Level"
label variable e_polity2 "Polity2"
scatter edi_mult e_polity2 if year == 1900, mlabangle(45) mlabsize(small) mlabcolor(black) mlabel(country_text_id) msymbol(none) graphregion(color(white)) title(" ", color(black)) saving(Figure_D2, replace)
graph export "Figure_D2.pdf", replace
corr edi_mult e_polity2 if year == 1900
sum edi_mult e_polity2 if year == 1900 & edi_mult != . & e_polity2 != .
scatter edi_mult e_polity2 if year == 2000, mlabangle(45) mlabsize(small) mlabcolor(black) mlabel(country_text_id) msymbol(none) graphregion(color(white)) title(" ", color(black)) saving(Figure_D3, replace)
* Figure D3: MPI level and Polity2 in 2000
graph export "Figure_D3.pdf", replace
corr edi_mult e_polity2 if year == 2000
sum edi_mult e_polity2 if year == 2000 & edi_mult != . & e_polity2 != .

* Table D6: Horse-race tests
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ preserve
qui gen alternate_index = e_polity2_pos_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_polity2_pos_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
restore
/* 2. */ preserve
qui gen alternate_index = e_uds_mean_pos_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_uds_mean_pos_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 3. */ preserve
qui gen alternate_index = contdim_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("contdim_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 4. */ preserve
qui gen alternate_index = partdim_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("partdim_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 5. */ preserve
qui gen alternate_index = v2x_partip_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("v2x_partip_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 6. */ preserve
qui gen alternate_index = v2xdl_delib_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("v2xdl_delib_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 7. */ preserve
qui gen alternate_index = v2x_gender_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("v2x_gender_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8. */ preserve
qui gen alternate_index = v2x_cspart_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("v2x_cspart_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 9. */ preserve
qui gen alternate_index = v2xcl_rol_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("v2xcl_rol_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 10. */ preserve
qui gen alternate_index = e_boix_regime_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_boix_regime_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 11. */ preserve
qui gen alternate_index = e_bnr_dem_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("e_bnr_dem_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 12. */ preserve
qui gen alternate_index = miller_mult_stock_1
qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 alternate_index e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("miller_mult_stock_1") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table D7: Varying aggregation rules
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel replace
/* 2. */ qui xtreg F.imr_gapminder_ipo_ln edi_min_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3. */ qui xtreg F.imr_gapminder_ipo_ln v2x_polyarchy_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4. */ qui xtreg F.imr_gapminder_ipo_ln edi_pca_stock_10  e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5. */ qui xtreg F.imr_gapminder_ipo_ln edi_ave_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
qui outreg2 using Table_D7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Figure D4: Change in predictive margins based on aggregation rules
use "2021_Democratization_replication_data_10yr.dta", clear
xtset country_id trend
/* 1. */ qui xtreg F.imr_gapminder_ipo_ln edi_mult_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
gen sample = e(sample)
centile edi_mult_stock_10 if sample == 1, centile(10 90)
sum edi_mult_stock_10 if sample == 1
drop sample
quietly margins, at(edi_mult_stock_10=(0(.25)1))
set scheme s2mono
marginsplot, ytitle("Infant mortality rate (ln)") xtitle("Multiplication (MPI)") recast(line) recastci(rarea) graphregion(color(white)) title("", color(black)) ciopts(color(gs14)) xline(0 .7672166) ylabel(3.25(.25)4) yscale(range(3.25 4)) saving(Figure_D4_part_1, replace)
graph export "Figure_D4_part_1.pdf", replace
margins, at(edi_mult_stock_10=(0 .7672166))
/* 2. */ qui xtreg F.imr_gapminder_ipo_ln edi_min_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
gen sample = e(sample)
centile edi_min_stock_10 if sample == 1, centile(10 90)
drop sample
quietly margins, at(edi_min_stock_10=(0(.25)1))
set scheme s2mono
marginsplot, ytitle("Infant mortality rate (ln)") xtitle("Minimum (weakest link)") recast(line) recastci(rarea) graphregion(color(white)) title("", color(black)) ciopts(color(gs14)) xline(0 .8666199) ylabel(3.25(.25)4) yscale(range(3.25 4))  saving(Figure_D4_part_2, replace)
graph export "Figure_D4_part_2.pdf", replace
margins, at(edi_min_stock_10=(0 .8666199))
/* 3. */ qui xtreg F.imr_gapminder_ipo_ln v2x_polyarchy_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
gen sample = e(sample)
centile v2x_polyarchy_stock_10 if sample == 1, centile(10 90)
sum v2x_polyarchy_stock_10 if sample == 1
drop sample
quietly margins, at(v2x_polyarchy_stock_10=(0(.25)1))
set scheme s2mono
marginsplot, ytitle("Infant mortality rate (ln)") xtitle("Electoral Democracy Index (addition and multiplication)") recast(line) recastci(rarea) graphregion(color(white)) title("", color(black)) ciopts(color(gs14)) xline(.0951586 .8380588) ylabel(3.25(.25)4) yscale(range(3.25 4))  saving(Figure_D4_part_3, replace)
graph export "Figure_D4_part_3.pdf", replace
margins, at(v2x_polyarchy_stock_10=(.0951586 .8380588))
/* 4. */ qui xtreg F.imr_gapminder_ipo_ln edi_pca_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
gen sample = e(sample)
centile edi_pca_stock_10 if sample == 1, centile(10 90)
sum edi_pca_stock_10 if sample == 1
drop sample
quietly margins, at(edi_pca_stock_10=(0(.25)1))
set scheme s2mono
marginsplot, ytitle("Infant mortality rate (ln)") xtitle("Factor scores (principal components)") recast(line) recastci(rarea) graphregion(color(white)) title("", color(black)) ciopts(color(gs14)) xline(.1902313 .9245331) ylabel(3.25(.25)4) yscale(range(3.25 4))  saving(Figure_D4_part_4, replace)
graph export "Figure_D4_part_4.pdf", replace
margins, at(edi_pca_stock_10=(.1902313 .9245331))
/* 5. */ qui xtreg F.imr_gapminder_ipo_ln edi_ave_stock_10 e_migdppcln_ipo i.year, fe vce(cluster country_id)
gen sample = e(sample)
centile edi_ave_stock_10 if sample == 1, centile(10 90)
sum edi_ave_stock_10 if sample == 1
drop sample
quietly margins, at(edi_ave_stock_10=(0(.25)1))
set scheme s2mono
marginsplot, ytitle("Infant mortality rate (ln)") xtitle("Average (arithmetic)") recast(line) recastci(rarea) graphregion(color(white)) title("", color(black)) ciopts(color(gs14)) xline(.1906963 .9274572) ylabel(3.25(.25)4) yscale(range(3.25 4))  saving(Figure_D4_part_5, replace)
graph export "Figure_D4_part_5.pdf", replace
margins, at(edi_ave_stock_10=(.1906963 .9274572))
* Combine graphs
graph combine Figure_D4_part_1.gph Figure_D4_part_2.gph Figure_D4_part_3.gph Figure_D4_part_4.gph Figure_D4_part_5.gph, ycommon cols(2) graphregion(color(white))
graph export "Figure_D4.pdf", replace

****************************************************************
****************************************************************
**************** Appendix E: Mediation Analysis ****************
****************************************************************
****************************************************************

* Table E1: Mediation analysis using annual data
use "2021_Democratization_replication_data_annual.dta", clear
/* 1 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id {
foreach depvar of varlist l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel replace 
}
}
}
}
/* 2 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 3 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist healthg {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 4 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1healthg {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 5 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist wdi_puhe  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 6 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist healthg  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 7 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist ht_regioncf {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 8 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1wdi_puhe {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 9 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1healthg  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 10 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 11 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1wdi_puhe {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year)(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year) ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument')  onecol excel append
}
}
}
/* 12 */ 
foreach indvar of varlist edi_mult {
foreach fe of varlist country_id {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 13 */ 
foreach indvar of varlist edi_mult {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 14 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1wdi_hec  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 15 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1healthcap  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 16 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1healthcap  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 17 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist  l2cme_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 18 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist   l2cme_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 19 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist  l2le_gapminder_ipo_85mln {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 20 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2le_gapminder_ipo_85mln {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_annual.dta", clear
qui xtset country_id year
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E1.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}

* Table E2: Mediation analysis using 10-year intervals
use "2021_Democratization_replication_data_10yr.dta", clear
/* 1 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id {
foreach depvar of varlist l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel replace 
}
}
}
}
/* 2 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 3 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist healthg {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 4 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1healthg {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 5 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist wdi_puhe  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 6 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist healthg  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 7 */
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist ht_regioncf {
foreach depvar of varlist l1imr_gapminder_ipo_ln {
foreach instrument of varlist pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 8 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1wdi_puhe {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 9 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1healthg  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 10 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 11 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1wdi_puhe {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year)(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year) ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument')  onecol excel append
}
}
}
/* 12 */ 
foreach indvar of varlist edi_mult {
foreach fe of varlist country_id {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 13 */ 
foreach indvar of varlist edi_mult {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 14 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1wdi_hec  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 15 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist  l2imr_gapminder_ipo_ln {
foreach instrument of varlist l1healthcap  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 16 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2imr_gapminder_ipo_ln  {
foreach instrument of varlist l1healthcap  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 17 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist  l2cme_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 18 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist   l2cme_gapminder_ipo_ln  {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 19 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist country_id  {
foreach depvar of varlist  l2le_gapminder_ipo_85mln {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
/* 20 */ 
foreach indvar of varlist edi_mult_stock_10 {
foreach fe of varlist  ht_regioncf {
foreach depvar of varlist  l2le_gapminder_ipo_85mln {
foreach instrument of varlist l1pexhlth  {
qui use "2021_Democratization_replication_data_10yr.dta", clear
qui xtset country_id trend
qui sureg (`instrument' `indvar' e_migdppcln_ipo i.year i.`fe')(`depvar' `instrument' `indvar' e_migdppcln_ipo i.year i.`fe')
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
qui local years=r(r)
qui tab country_id if e(sample) == 1, nofreq
qui local countries=r(r)
/* total effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar']
qui mat b1=r(b)
qui mat v1=r(V)
qui local total_beta=b1[1,1]
qui local total_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* indirect effect */ qui nlcom [`instrument']_b[`indvar']*[`depvar']_b[`instrument']
qui mat b1=r(b)
qui mat v1=r(V)
qui local indirect_beta=b1[1,1]
qui local indirect_zscore=round((b1[1,1])/(sqrt(v1[1,1])),.001)
/* percent mediated */ qui nlcom 100*([`instrument']_b[`indvar']*[`depvar']_b[`instrument'])/([`instrument']_b[`indvar']*[`depvar']_b[`instrument'] + [`depvar']_b[`indvar'])
qui mat b1=r(b)
qui local percent_mediated=b1[1,1]
qui outreg2 using Table_E2.xls, label se bdec(3) noni noobs nor nocon nonot drop(`instrument' `indvar' e_migdppcln_ipo i.year i.`fe') ctitle(" ") addstat("Total beta", `total_beta', "Total z-score", `total_zscore', "Indirect beta", `indirect_beta', "Indirect z-score", `indirect_zscore', "Percent mediated", `percent_mediated', "Countries", `countries', "Years", `years', "Observations", e(N)) addtext(DV, `depvar', IV, `indvar', Instrument, `instrument', FE, `fe')  onecol excel append
}
}
}
}
